#include "hub.h"

Hub::Hub()
{
    m_pMyCamera=new MyCamera;
    m_pImageViewer=new ImageViewer;
    connect(m_pMyCamera,&MyCamera::sigCurrentImgQ,m_pImageViewer,&ImageViewer::showImage);
    m_pImageProcess=new ImageProcess;
    connect(m_pMyCamera,&MyCamera::sigCurrentImgQ,m_pImageProcess,&ImageProcess::setImg);

    m_pImageProcess->moveToThread(&m_Thread);
    connect(this,&Hub::startProcess,m_pImageProcess,&ImageProcess::processImg);
    connect(m_pImageProcess,&ImageProcess::processFinished,[this](){
        qDebug() << "ProcessFinished in  : " << QThread::currentThreadId();
        emit callQmlRefreshImg();});
    m_Thread.start();
}

void Hub::openCam()
{
    m_pMyCamera->openCam();
}
void Hub::closeCam()
{
    m_pMyCamera->closeCam();
}

//void Hub::processImg()  //此函数在主线程执行，那么其内的代码也在主线程执行
//{
//    m_pImageProcess->processImg();
//}
